package com.ruoyi.project.yuwen.audiototal.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.yuwen.audiototal.domain.AudioTotal;
import com.ruoyi.project.yuwen.audiototal.service.IAudioTotalService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 朗诵统计Controller
 * 
 * @author shixiangwen
 * @date 2021-04-26
 */
@Controller
@RequestMapping("/yuwen/audiototal")
public class AudioTotalController extends BaseController
{
    private String prefix = "yuwen/audiototal";

    @Autowired
    private IAudioTotalService audioTotalService;

    @RequiresPermissions("yuwen:audiototal:view")
    @GetMapping()
    public String audiototal()
    {
        return prefix + "/audiototal";
    }

    /**
     * 查询朗诵统计列表
     */
    @RequiresPermissions("yuwen:audiototal:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AudioTotal audioTotal)
    {
        startPage();
        List<AudioTotal> list = audioTotalService.selectAudioTotalList(audioTotal);
        return getDataTable(list);
    }

    /**
     * 导出朗诵统计列表
     */
    @RequiresPermissions("yuwen:audiototal:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AudioTotal audioTotal)
    {
        List<AudioTotal> list = audioTotalService.selectAudioTotalList(audioTotal);
        ExcelUtil<AudioTotal> util = new ExcelUtil<AudioTotal>(AudioTotal.class);
        return util.exportExcel(list, "audiototal");
    }

    /**
     * 新增朗诵统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存朗诵统计
     */
    @RequiresPermissions("yuwen:audiototal:add")
    @Log(title = "朗诵统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AudioTotal audioTotal)
    {
        return toAjax(audioTotalService.insertAudioTotal(audioTotal));
    }

    /**
     * 修改朗诵统计
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AudioTotal audioTotal = audioTotalService.selectAudioTotalById(id);
        mmap.put("audioTotal", audioTotal);
        return prefix + "/edit";
    }

    /**
     * 修改保存朗诵统计
     */
    @RequiresPermissions("yuwen:audiototal:edit")
    @Log(title = "朗诵统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AudioTotal audioTotal)
    {
        return toAjax(audioTotalService.updateAudioTotal(audioTotal));
    }

    /**
     * 删除朗诵统计
     */
    @RequiresPermissions("yuwen:audiototal:remove")
    @Log(title = "朗诵统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(audioTotalService.deleteAudioTotalByIds(ids));
    }
}
